#include "rect.h"
#include <sdl/sdl.h>

Rect::Rect(){
    mX = 0;
    mY = 0;
    mW = 0;
    mH = 0;
}
Rect::Rect(int x,int y,int w,int h){
    mX = x;
    mY = y;
    mW = w;
    mH = h;
}
        
void Rect::setDimension(int x,int y,int w,int h){
    mX = x;
    mY = y;
    mW = w;
    mH = h;
}

SDL_Rect* Rect::toSDLRect(){
    SDL_Rect *tmp = (SDL_Rect*)malloc(sizeof(SDL_Rect));
    tmp->x = mX;
    tmp->y = mY;
    tmp->w = mW;
    tmp->h = mH;
    return tmp;
} 


bool Rect::pointIn(int x,int y){
    if(x >= mX && x <= mX+mW && y >= mY && y <= mY+mW){
        return true;
    }else return false;
}

bool Rect::pointIn(Point p){
    return pointIn(p.getX(),p.getY());
}
